#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time: 2022/9/15 15:00
# @Author: 刘航
# @Email: xxx@gmail.com
# @File：main_page.py

"""
主页模块
"""
from config.config import HOST
from pages.cus_mag_pages.base_page import BasePage
from selenium.webdriver.common.by import By

class MainPage(BasePage):
    """类属性"""
    url = "http://{}/crm/index.php?m=dynamic&a=index".format(HOST)
    status_locator = (By.XPATH, "/html/body/div[5]/div[2]")
    cule_locator = (By.LINK_TEXT,"线索")
    customer_locator = (By.LINK_TEXT,"客户")
    com_opt_locator = (By.LINK_TEXT, "商机")
    produc_locator = (By.LINK_TEXT,"产品")
    task_locator = (By.LINK_TEXT,'任务')
    schedule_locator = (By.LINK_TEXT,"日程")
    contract_locator = (By.LINK_TEXT,"合同")
    financial_locator = (By.LINK_TEXT,"财务")
    more_locator = (By.LINK_TEXT,"更多")
    log_locator = (By.LINK_TEXT,"日志")
    knowledge_locator = (By.LINK_TEXT,"知识")
    marketing_locator = (By.LINK_TEXT,"营销")
    message_locator = (By.LINK_TEXT,"站内信")



    def get_login_status(self):
        """获取登录状态"""
        element = self.driver.find_element(*self.status_locator)
        return element.text
    def cule_click(self):
        """点击主页线索"""
        self.driver.find_element(*self.cule_locator).click()
    def customer_click(self):
        """主页客户按钮"""
        self.driver.find_element(*self.customer_locator).click()
    def com_opt_clock(self):
        """主页商机按钮"""
        self.driver.find_element(*self.com_opt_locator).click()
    def produc_click(self):
        """主页产品按钮"""
        self.driver.find_element(*self.produc_locator).click()
    def task_click(self):
        """主页任务按钮"""
        self.driver.find_element(*self.task_locator).click()
    def schedule_click(self):
        """主页日程按钮"""
        self.driver.find_element(*self.schedule_locator).click()
    def contract_click(self):
        """主页合同按钮"""
        self.driver.find_element(*self.contract_locator).click()
    def financial_click(self):
        """主页财务按钮"""
        self.driver.find_element(*self.financial_locator).click()
    def log_click(self):
        """主页日志按钮"""
        self.driver.find_element(*self.more_locator).click()
        self.driver.find_element(*self.log_locator).click()
    def knowledge_click(self):
        """主页知识按钮"""
        self.driver.find_element(*self.more_locator).click()
        self.driver.find_element(*self.knowledge_locator).click()
    def marketing_click(self):
        """主页营销按钮"""
        self.driver.find_element(*self.more_locator).click()
        self.driver.find_element(*self.marketing_locator).click()
    def message_click(self):
        """主页营销按钮"""
        self.driver.find_element(*self.more_locator).click()
        self.driver.find_element(*self.message_locator).click()

